package com.thiswhyme.common.expection;

import com.thiswhyme.common.response.IResponseCode;
import com.thiswhyme.common.response.ResponseCode;
import lombok.Getter;

/**
 * 业务异常
 *
 * Created by thiswhyme on 2019-12-11.
 */
@Getter
public class BusinessException extends RuntimeException {

	private String code;

	private String msg;

	public BusinessException(String code, String msg, Throwable throwable) {
		super(throwable);
		this.code = code;
		this.msg = msg;
	}

	public BusinessException(String code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public BusinessException(IResponseCode responseCode, Throwable throwable) {
		this(responseCode.getCode(), responseCode.getMsg(), throwable);
	}

	public BusinessException(IResponseCode responseCode) {
		this(responseCode.getCode(), responseCode.getMsg());
	}

	public BusinessException(String msg) {
		this(ResponseCode.SYSTEM_EXCEPTION.getCode(), msg);
	}

	public BusinessException() {
		this(ResponseCode.SYSTEM_EXCEPTION.getMsg());
	}
}
